Skip to content

[lexical-playground] Bug Fix: Paste Google Docs date chips as all-day dates - #9932

Open
mayrang wants to merge 2 commits into
meta:mainfrom
mayrang:fix/datetime-gdocs-all-day
Open

mayrang wants to merge 2 commits into
meta:mainfrom
mayrang:fix/datetime-gdocs-all-day

Conversation

@mayrang

@mayrang mayrang commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Follow-up to #9930. A Google Docs date chip pastes as a timed chip, and from UTC+12 east it lands on the next day. A time shown without a time zone pastes at another time. Google stores a chip without a time as noon UTC of its day (tv_s 1794916800 for Nov 17, the same in a Seoul tab and a Pacific/Kiritimati tab), and GoogleDocsDateRule stores that instant, so Nov 17 shows as Tue Nov 17 2026 21:00 in Seoul and Wed Nov 18 2026 01:00 in Pacific/Apia.

A chip with dfie_tpt 0 now pastes as the all-day date of its UTC calendar day (2026-11-17). dfie_tpt is what tells the two apart: a chip set to 12:00 UTC has the same tv_s with dfie_tpt 2, and a chip whose time was removed keeps dfie_tzi but goes back to dfie_tpt 0. A chip whose time is shown without a time zone (dfie_tpt 1) keeps only its wall clock time, written as UTC: hiding the zone of a 12:00 chip set in Seoul changes tv_s from 03:00Z to 12:00Z, the same payload as a 12:00 UTC chip with its zone hidden. It now pastes as that wall clock time in the time zone it is pasted in, the same as typing it in the picker. The node stores instants and all-day dates only, so other time zones show that instant converted. Showing 12:00 in every time zone would need a third kind of value on the node, a time without a zone next to instants and all-day dates, so that is left for a separate change if it is wanted. A chip that shows its time zone (dfie_tpt 2), other dfie_tpt values and years outside 0000-9999 stay instants as before. A chip whose dat_df is null (which threw and dropped the pasted paragraph) or whose timestamp is out of range (which made an Invalid Date chip) now keeps its text.

Changeset

None, playground only.

Test plan

The payloads in the tests are real clipboard data copied from Google Docs: date chips made in a Seoul tab and in a Pacific/Kiritimati tab, a chip with its time removed, chips at 12:00 in Seoul and in UTC, and a 12:00 chip with its time zone hidden.

Before

Pasting the copied chips into the playground (Chromium timezoneId):

date chip           Asia/Seoul    stored "2026-11-17T12:00:00.000Z"  text "Tue Nov 17 2026 21:00"
date chip           Pacific/Apia  stored "2026-11-17T12:00:00.000Z"  text "Wed Nov 18 2026 01:00"
12:00, no zone      Asia/Seoul    stored "2026-11-17T12:00:00.000Z"  text "Tue Nov 17 2026 21:00"
12:00, no zone      Pacific/Apia  stored "2026-11-17T12:00:00.000Z"  text "Wed Nov 18 2026 01:00"

TZ=UTC pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeImport.test.ts packages/lexical-playground/__tests__/unit/DateTimeNodeTimeZone.test.ts

AssertionError: expected [ '2026-11-17T12:00:00.000Z' ] to deeply equal [ '2026-11-17' ]
TypeError: Cannot read properties of null (reading 'dfie_ts')
      Tests  12 failed | 14 passed (26)

After

date chip           Asia/Seoul    stored "2026-11-17"                text "Tue Nov 17 2026"
date chip           Pacific/Apia  stored "2026-11-17"                text "Tue Nov 17 2026"
12:00, no zone      Asia/Seoul    stored "2026-11-17T03:00:00.000Z"  text "Tue Nov 17 2026 12:00"
12:00, no zone      Pacific/Apia  stored "2026-11-16T23:00:00.000Z"  text "Tue Nov 17 2026 12:00"

The 12:00 UTC timed chip still pastes as 2026-11-17T12:00:00.000Z.

      Tests  26 passed (26)

TZ=UTC pnpm run test-unit: 40,095 passed, 0 failed. tsc, tsc-test, eslint and prettier pass. Chromium e2e DateTime.spec and HTML.spec: 12 passed.

… dates

## Description

Follow-up to meta#9930. A Google Docs date chip pastes as a timed chip, and from UTC+12 east it lands on the next day. Google stores a chip without a time as noon UTC of its day (`tv_s` 1794916800 for Nov 17, the same in a Seoul tab and a Pacific/Kiritimati tab), and `GoogleDocsDateRule` stores that instant, so Nov 17 shows as `Tue Nov 17 2026 21:00` in Seoul and `Wed Nov 18 2026 01:00` in Pacific/Apia.

A chip with `dfie_tpt` 0 now pastes as the all-day date of its UTC calendar day (`2026-11-17`). `dfie_tpt` is what tells the two apart: a chip set to 12:00 UTC has the same `tv_s` with `dfie_tpt` 2, and a chip whose time was removed keeps `dfie_tzi` but goes back to `dfie_tpt` 0. Timed chips, other `dfie_tpt` values and years outside 0000-9999 stay instants as before. A chip whose `dat_df` is `null` (which threw and dropped the pasted paragraph) or whose timestamp is out of range (which made an `Invalid Date` chip) now keeps its text.

## Changeset

None, playground only.

## Test plan

The payloads in the tests are real clipboard data copied from Google Docs: date chips made in a Seoul tab and in a Pacific/Kiritimati tab, a chip with its time removed, and chips at 12:00 in Seoul and in UTC.

### Before

Pasting the copied date chip into the playground (Chromium `timezoneId`):

```
Asia/Seoul    stored "2026-11-17T12:00:00.000Z"  text "Tue Nov 17 2026 21:00"
Pacific/Apia  stored "2026-11-17T12:00:00.000Z"  text "Wed Nov 18 2026 01:00"
```

`TZ=UTC pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeImport.test.ts packages/lexical-playground/__tests__/unit/DateTimeNodeTimeZone.test.ts`

```
AssertionError: expected [ '2026-11-17T12:00:00.000Z' ] to deeply equal [ '2026-11-17' ]
TypeError: Cannot read properties of null (reading 'dfie_ts')
      Tests  12 failed | 14 passed (26)
```

### After

```
Asia/Seoul    stored "2026-11-17"  text "Tue Nov 17 2026"
Pacific/Apia  stored "2026-11-17"  text "Tue Nov 17 2026"
```

The 12:00 UTC timed chip still pastes as `2026-11-17T12:00:00.000Z`.

```
      Tests  26 passed (26)
```

`TZ=UTC pnpm run test-unit`: 40,095 passed, 0 failed. `tsc`, `tsc-test`, eslint and prettier pass. Chromium e2e `DateTime.spec` and `HTML.spec`: 12 passed.
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Nov 17, 2026 5:54am UTC
lexical-playground Ready Ready Preview Nov 17, 2026 5:54am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 17, 2026
@rootnode-bot

rootnode-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 17, 2026, 6:07 AM UTC

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
lexical

npm i https://pkg.pr.new/lexical@9932

@lexical/a11y

npm i https://pkg.pr.new/@lexical/a11y@9932

@lexical/clipboard

npm i https://pkg.pr.new/@lexical/clipboard@9932

@lexical/code

npm i https://pkg.pr.new/@lexical/code@9932

@lexical/code-core

npm i https://pkg.pr.new/@lexical/code-core@9932

@lexical/code-prism

npm i https://pkg.pr.new/@lexical/code-prism@9932

@lexical/code-shiki

npm i https://pkg.pr.new/@lexical/code-shiki@9932

@lexical/compiler

npm i https://pkg.pr.new/@lexical/compiler@9932

@lexical/devtools-core

npm i https://pkg.pr.new/@lexical/devtools-core@9932

@lexical/dragon

npm i https://pkg.pr.new/@lexical/dragon@9932

@lexical/eslint-plugin

npm i https://pkg.pr.new/@lexical/eslint-plugin@9932

@lexical/extension

npm i https://pkg.pr.new/@lexical/extension@9932

@lexical/fast-check

npm i https://pkg.pr.new/@lexical/fast-check@9932

@lexical/file

npm i https://pkg.pr.new/@lexical/file@9932

@lexical/hashtag

npm i https://pkg.pr.new/@lexical/hashtag@9932

@lexical/headless

npm i https://pkg.pr.new/@lexical/headless@9932

@lexical/history

npm i https://pkg.pr.new/@lexical/history@9932

@lexical/html

npm i https://pkg.pr.new/@lexical/html@9932

@lexical/internal

npm i https://pkg.pr.new/@lexical/internal@9932

@lexical/link

npm i https://pkg.pr.new/@lexical/link@9932

@lexical/list

npm i https://pkg.pr.new/@lexical/list@9932

@lexical/mark

npm i https://pkg.pr.new/@lexical/mark@9932

@lexical/markdown

npm i https://pkg.pr.new/@lexical/markdown@9932

@lexical/mdast

npm i https://pkg.pr.new/@lexical/mdast@9932

@lexical/offset

npm i https://pkg.pr.new/@lexical/offset@9932

@lexical/overflow

npm i https://pkg.pr.new/@lexical/overflow@9932

@lexical/plain-text

npm i https://pkg.pr.new/@lexical/plain-text@9932

@lexical/react

npm i https://pkg.pr.new/@lexical/react@9932

@lexical/rich-text

npm i https://pkg.pr.new/@lexical/rich-text@9932

@lexical/selection

npm i https://pkg.pr.new/@lexical/selection@9932

@lexical/table

npm i https://pkg.pr.new/@lexical/table@9932

@lexical/tailwind

npm i https://pkg.pr.new/@lexical/tailwind@9932

@lexical/text

npm i https://pkg.pr.new/@lexical/text@9932

@lexical/utils

npm i https://pkg.pr.new/@lexical/utils@9932

@lexical/y

npm i https://pkg.pr.new/@lexical/y@9932

@lexical/yjs

npm i https://pkg.pr.new/@lexical/yjs@9932

commit: 190d4bf

@rootnode-bot rootnode-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — this looks good. A Google Docs date chip with no time now pastes as an all-day date of its day, so it reads the same in every time zone, and a chip with a null dat_df or an out-of-range timestamp now keeps its text instead of throwing or becoming an Invalid Date chip. The new cases fail on main and pass on this branch, and in the playground the chip reads Tue Nov 17 2026 in Pacific/Apia, Asia/Seoul and America/New_York (before: Wed Nov 18 2026 01:00, Tue Nov 17 2026 21:00 and Tue Nov 17 2026 07:00), while a 12:00 Seoul timed chip is unchanged.

One optional, non-blocking suggestion:

  • packages/lexical-playground/__tests__/unit/DateTimeImport.test.ts:178-182 — unlike the other cases, which come from copied chips, 'a chip with another time type' is the date-chip payload with only dfie_tpt changed to 1, and it pins today's result, the instant 2026-11-17T12:00:00.000Z. Nothing regresses, but if Google stores a time with no zone the way it stores a date-only chip (its wall clock read as UTC), this case locks in the same east-of-UTC shift for timed chips: a 12:00 chip would paste as 21:00 in Seoul. Consider replacing it with a copied dfie_tpt 1 chip and asserting what that chip should show, or dropping it so a later fix doesn't have to undo it.

No changeset is needed: CONTRIBUTING.md and AGENTS.md exempt playground-only changes.

Automated review (maintainer link)

… zone as that time

## Description

A Google Docs chip whose time is shown without a time zone (`dfie_tpt` 1) keeps only its wall clock time, written as UTC: hiding the zone of a 12:00 chip set in Seoul changes `tv_s` from 03:00Z to 12:00Z, the same payload as a 12:00 UTC chip with its zone hidden. It pasted as 12:00 UTC, so `Tue Nov 17 2026 21:00` in Seoul.

It now pastes as that wall clock time in the time zone it is pasted in, the same as typing 12:00 in the picker. The node stores instants and all-day dates only, so the stored value is that local time as an instant, and other time zones show it converted. A chip that shows its time zone (`dfie_tpt` 2) keeps its instant.

## Changeset

None, playground only.

## Test plan

### Before

`TZ=UTC pnpm vitest run --project unit packages/lexical-playground/__tests__/unit/DateTimeNodeTimeZone.test.ts` (the 12:00 chip without a time zone, pasted in each zone):

```
America/New_York  - "12:00"  + "07:00"
Asia/Seoul        - "12:00"  + "21:00"
America/Santiago  - "12:00"  + "09:00"
Pacific/Apia      - "12:00"  + "01:00"
Atlantic/Azores   - "12:00"  + "11:00"
      Tests  5 failed (5)
```

### After

```
      Tests  26 passed (26)
```

Pasting the copied chip into the playground (Chromium `timezoneId`): `Tue Nov 17 2026 12:00` in Asia/Seoul and Pacific/Apia (before: `21:00` and `Wed Nov 18 2026 01:00`). `TZ=UTC pnpm run test-unit`: 40,095 passed, 0 failed.

@rootnode-bot rootnode-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks for tracking down what dfie_tpt means and backing it with copied clipboard payloads.

  • Chips with dfie_tpt 0 now paste as the all-day date of their UTC day (packages/lexical-playground/src/plugins/DateTimeExtension/index.tsx:95-106). That keeps Nov 17 on Nov 17 from UTC+12 eastward and stores the same YYYY-MM-DD form the date picker writes for an all-day date.
  • Chips with dfie_tpt 1 now paste as their wall-clock time in the zone where they are pasted, the same as choosing that time in the picker. The PR description is right that showing 12:00 in every zone would need a new kind of value on the node, so leaving that for a separate change makes sense.
  • The dat_df == null and invalid-date guards (index.tsx:80-90) now fall back to the chip's text instead of throwing or creating an empty chip.
  • Replacing the dfie_tpt 1 case with a copied chip and asserting the local 12:00 result addresses my earlier note on DateTimeImport.test.ts. The new cases fail against main and pass with this change, and the five-zone test in DateTimeNodeTimeZone.test.ts covers the zone-hidden chip outside UTC.

No changeset is needed: CONTRIBUTING.md exempts playground-only changes.

Automated review (maintainer link)

This branch was successfully deployed

2 active deployments
Preview – lexical — 190d4bfc Deployed Nov 17, 2026 by vercel[bot]
Preview – lexical-playground — 190d4bfc Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant